Skip to content

Improve reliability of wait_and_check_bitcoind#9240

Open
NicolasDorier wants to merge 1 commit into
ElementsProject:masterfrom
btcpayserver:reliable-rpcwait
Open

Improve reliability of wait_and_check_bitcoind#9240
NicolasDorier wants to merge 1 commit into
ElementsProject:masterfrom
btcpayserver:reliable-rpcwait

Conversation

@NicolasDorier

@NicolasDorier NicolasDorier commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

bitcoin-cli -rpcwait works probably as expected if the blocks are loading before core lightning start. But doesn't if BitcoinD isn't listening at all before Core Lightning wait, we observed the following behavior.

  • Timestamp: 0: Core Lightning Starts and wait RPC
  • Timestamp: 10: Bitcoind starts
  • Timestamp: 30: Core Lightning fails (RPC connection timed out)
  • Timestamp: 31: Core Lightning Container crashes, docker restart it
  • Timestamp: 32: Core Lightning Starts, AND detect bitcoind started

Rather than waiting for 30 seconds, this PR wait 30 times for 1 seconds. This fix the issue for us.

  • Timestamp: 0: Core Lightning Starts and wait RPC
  • Timestamp: 10: Bitcoind starts
  • Timestamp: 11: Core Lightning detect bitcoind started

This is a patch we are using in BTCPay Server deployments. Not really critical in production scenario, but it was causing our tests to fail as lightningd was taking 30 seconds to properly start.

Changelog-Fixed: Fixed spurious bitcoind startup failures by retrying bitcoin-cli -rpcwait checks when RPC briefly fails.
@NicolasDorier NicolasDorier marked this pull request as ready for review June 22, 2026 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant